package com.ruoyi.app.controller.shop.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.shop.ShopConfigDO;
import com.ruoyi.common.entity.VO.shop.ShopConfigSearchVO;
import com.ruoyi.common.entity.VO.shop.ShopConfigVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IShopConfigMapper extends BaseMapper<ShopConfigDO> {
    List<ShopConfigVO> searchList(ShopConfigSearchVO shopConfigSearchVO);

    @Select("SELECT COUNT(0) FROM sys_config WHERE is_shop=1")
    int countConfig();

    List<ShopConfigDO> searchBackList(@Param("ids") String ids);

    @Select("SELECT config_id FROM shop_config WHERE shop_id=#{shopId}")
    List<Long> countShopConfig(Long shopId);

    @Select("SELECT shop_id shopId,sc.config_value configValue FROM shop_config sc " +
            "LEFT JOIN sys_config c ON sc.config_id=c.config_id " +
            "WHERE config_key =#{configKey}")
    List<ShopConfigVO> searchListByKey(@Param("configKey") String configKey);

    @Select("SELECT sc.config_value FROM shop_config sc " +
            "LEFT JOIN sys_config c ON sc.config_id=c.config_id " +
            "WHERE config_key =#{configKey} and shop_id=#{shopId}")
    String searchValueByKey(@Param("configKey") String configKey, @Param("shopId") Long shopId);
}
